package com.dna.api;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.dna.annotation.IgnoreAuth;
import com.dna.annotation.LoginUser;
import com.dna.entity.UserEntity;
import com.dna.service.MenuService;
import com.dna.service.UserService;
import com.dna.utils.R;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

/**
 * API对外测试接口
 *
 */
@RestController
@RequestMapping("/api")
@Api("测试接口")
public class ApiTestController {

	@Autowired
	private UserService userService;
	
	@Autowired
	private MenuService menuService;
	
    /**
     * 获取用户信息
     */
    @GetMapping("userInfo")
    @ApiOperation(value = "获取用户信息")
    @ApiImplicitParam(paramType = "header", name = "token", value = "token", required = true)
    public R userInfo(@LoginUser UserEntity user){
        return R.ok().put("user", user);
    }

    /**
     * 获取用户信息
     */
    @GetMapping("userList")
    public R userList(){
    	List<UserEntity> userList = userService.queryAll();
        return R.ok().put("userList", userList);
    }
    
    /**
     * 获取用户信息
     */
    @GetMapping("menus")
    public void menus(){
    	
    	   	
//        menuService.delete(1l);
    }
    
    
    
    
    /**
     * 忽略Token验证测试
     */
    @IgnoreAuth
    @GetMapping("notToken")
    @ApiOperation(value = "忽略Token验证测试")
    public R notToken(){
        return R.ok().put("msg", "无需token也能访问。。。");
    }
    
    
}
